package com.itmuch.cloud.study.controller;

import com.itmuch.cloud.study.entity.User;
import com.itmuch.cloud.study.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Optional;

/**
 * user api
 * @author WangGang
 * @date 2021/11/13
 */
@RequestMapping("index")
@RestController
public class UserController {
  @Autowired
  private UserRepository userRepository;

  /**
   * get user by id
   * @param id userId
   * @param name name
   * @author WangGang
   * @date 2021/11/13
   */
  @GetMapping("/{id}/{name}")
  public User findById(@PathVariable Long id,@PathVariable String name) {
    User user =new User();
    user.setAge(23);
    user.setUsername(name);
    user.setBalance(BigDecimal.valueOf(56));
    user.setId(id);
    user.setName("Dear "+name);

    return user;
  }
}
